<template>
  <container-tabs
    :menu-list="menuList"
    :is-tab="isTab"
    :options="options"
    :isPathHideTab="isPathHideTab"
    @redirect="menuRedirect"
  >
    <template slot="top">
      <Myheader v-if="getIsShow()" ref="header" :navList="navList" :verify-empty="verifyEmpty"/>
      <IframeHeader v-if="isShowIframeHeaderFlag" />
    </template> 
    
  </container-tabs>
</template>

<script>
import Myheader from './header'
import IframeHeader from './iframeHeader'
import { getMenuList } from '@/api'
export default {
  name: 'MainContainer',
  data() {
    return {
      containerShow: '',
      menuList: [],
    };
  },
  components: {
    Myheader,
    IframeHeader
  },
  props: {
    navList: {
      type: Array,
      default: () => {
        return []
      }
    },
    isTab: {
      type: Boolean,
      default: true,
    },
    verifyEmpty: {
      type: Boolean,
      default: false,
    },
    options: {
      type: Array,
      default() {
        return [];
      },
    },
    isShowIframeHeader: {
      type: Boolean,
      default: true,
    },
    isPathHideTab: {
      type: Boolean,
      default: false,
    },
  },
  watch: {
    isTab() {
      if (this.isTab) {
        this.getChildList();
      }
    }
  },
  mounted() {
    if (this.isTab) {
      this.getChildList();
    }
  },
  computed: {
    isShowIframeHeaderFlag() {
      return self.frameElement && self.frameElement.tagName == "IFRAME" && this.isShowIframeHeader
    },
  },
  methods: {
    getIsShow () {
      return top == self
    },
    async getChildList() {
      if (!this.$route.query.menuId && !sessionStorage.getItem('menuId')) {
        return;
      }

      let res = await getMenuList({
        typeList: ['normal', 'redirect'],
        parentId: this.$route.query.menuId || sessionStorage.getItem('menuId')
      });

      this.menuList = res.rows || [];
    },
    async menuRedirect (item) {
      let url = await this.$menuRedirectBaseUrl(item, {
        enterpriseid: this.$route.query.enterpriseid || localStorage.getItem('userEnterpriseid')
      })

      window.open(url)
    }
  },
};
</script>
<style lang="scss" scoped>
::v-deep .menu-box {
  height: 54px;
  padding-top: 10px;
}
</style>
